<?php
/**
 * 
 * @author Paolo Bertuzzo
 *
 */
namespace Catalog\Helper;

use Zend\View\Helper\HelperInterface;
use Zend\View\Helper\AbstractHelper;
use Catalog\Service\ProductService;
use Zend\View\Model\ViewModel;
use Zend\View\Helper\Partial;
use Utilities\Session\SessionFacade;

class CategoryTreeHelper extends Partial
{
    
    /**
     */
    protected $productService;
    
    /**
     * 
     * @param ProductService $productService
     */
    public function __construct(ProductService $productService)
    {
    	$this->productService = $productService;
    }
    
    /**
     * (non-PHPdoc)
     * @see \Zend\View\Helper\Partial::__invoke()
     */
    public function __invoke($name = NULL, $values = NULL)
    {
        return parent::__invoke('helper/category_tree', array(
        	'categories' => $this->productService->getCategories($this->getLanguage())
        ));
    }

    /**
     * 
     */
    private function getLanguage()
    {
    	$sessionFacade = new SessionFacade();
    	
    	return $sessionFacade->getStore()->getLanguage();
    }
    
}

?>